package com.hmsm.sys.action;

import com.hmsm.server.base.BaseAction;
import com.hmsm.sys.po.Menu;
import com.hmsm.sys.po.UserInfo;
import com.lzyyj.common.Page;

@SuppressWarnings("serial")
public class MenuAction extends BaseAction<UserInfo> {

	private Page<Menu> page = new Page<Menu>();
	
	public Page<Menu> getPage() {
		return page;
	}

	public void setPage(Page<Menu> page) {
		this.page = page;
	}
	
	private Menu item;

	public Menu getItem() {
		return item;
	}

	public void setItem(Menu item) {
		this.item = item;
	}

	public MenuAction(){
	}
	
	public String manage(){
		page = getMenuService().manage(page, getSessionUser());
		return SUCCESS;
	}
	
	public String save(){
		try {
			item = (Menu) getMenuService().save(item, getSessionUser());
			mapResult.put("success", true);
		} catch (Exception e) {
			e.printStackTrace();
			mapResult.put("success", false);
			mapResult.put("errorMessage", e.getMessage());
		}
		return "json";
	}
	
	public String del(){
		try {
			getMenuService().del(item, getSessionUser());
			mapResult.put("success", true);
		} catch (Exception e) {
			e.printStackTrace();
			mapResult.put("success", false);
			mapResult.put("errorMessage", e.getMessage());
		}
		return "json";
	}
	
}
